package com.utf8convert;

import java.io.File;
import java.io.FilenameFilter;

/**
 * Created by Coolcow on 2015/11/23 0023.
 */
public class FileFilter implements FilenameFilter {
    private String type;

    public FileFilter(String type) {
        this.type = type;
    }

    /**
     * Tests if a specified file should be included in a file list.
     *
     * @param dir  the directory in which the file was found.
     * @param name the name of the file.
     * @return <code>true</code> if and only if the name should be
     * included in the file list; <code>false</code> otherwise.
     */
    @Override
    public boolean accept(File dir, String name) {
        File file = new File(name);
        return file.getName().endsWith(type);
    }
}
